package com.zhuqieli.database_learn.enummeration;

import com.zhuqieli.database_learn.utils.IResponseStatus;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

public enum ReturnStatusEnum implements IResponseStatus {

    SUCCESS("200", "成功");


    /**
     * 状态码
     */
    private final String code;

    /**
     * name 状态名称
     */
    private final String message;

    ReturnStatusEnum(String code, String message) {

        this.code = code;
        this.message = message;
    }

    @Override
    public String getCode() {

        return code;
    }

    @Override
    public String getMsg() {

        return message;
    }

    /**
     * 获取全响应信息
     *
     * @param originalMessage 初始描述信息
     * @param extraMessage    额外描述信息
     * @return 全部响应信息
     */
    public static String getFullMessage(String originalMessage, String... extraMessage) {

        if (StringUtils.isEmpty(originalMessage) || ArrayUtils.isEmpty(extraMessage)) {
            return originalMessage;
        }
        StringBuilder builder = new StringBuilder(originalMessage + "(");
        for (int i = 0; i < extraMessage.length; i++) {
            builder.append(extraMessage[i]);
            if (i != extraMessage.length - 1) {
                builder.append(";");
            }
        }
        originalMessage = builder.toString();
        originalMessage = originalMessage + ")";
        return originalMessage;
    }


}
